<?php

//This is a camper array
$camper = array('name' 		=> "Lee Pepper",
		'age' 		=> 24,
		'gender'	=> "Male",
		'grade' 	=> "Adult",
		'address'	=> "804 E Gibbon",
		'parents'	=> "Self",
		'city'		=> "Laramie",
		'state'		=> "WY",
		'zip'		=> "82072",
		'phone1'	=> "3073213412",
		'phone2'	=> "3074603837",
		'email'		=> "pepperlk@gmail.com",
		'pickup_name'	=> "Self",
		'pickup_cell'	=> "307.321.3412",
		'shirt_size'	=> "Large",
		'shirt_style'	=> "Hoodie",
		'emg_name'	=> "Ashley",
		'emg_relation'	=> "Wife",
		'emg_city'	=> "Laramie",
		'emg_phone1'	=> "3073210616",
		'emg_phone2'	=> "3073210616",
		'emg_phone3'	=> "3073210616",
		'ins_company'	=> "Company",
		'ins_policy'	=> "4+6456465",
		'med_last_exam'	=> "6/6/01",
		'med_current_probs' => "false",
		'med_under_care' => "false",
		'med_since_last' => "false",
		'med_mmr' 	=> "vac",
		'med_pertussis'	=> "vac",
		'med_cpox'	=> "dis",
		'med_tetanus'	=> "6/6/01",
		'med_dip'	=> "6/6/01",
		'med_other'	=> "notes here",
		'med_diabetes'	=> "false",
		'med_fainting'	=> "false",
		'med_bleeding'	=> "false",
		'med_allergy'	=> "false",
		'med_special_care' => "false",
		'med_asthma'	=> "false",
		'med_convulsions' => "false",
		'med_heart'	=> "false",
		'med_contacts'	=> "false",
		'med_restriction' => "false",
		'med_meds'	=> "false",
		'bill_family'	=> "Pepper",
		'bill_due'	=> "55.00");

build_pdf($camper);



function build_pdf($camper)
{
	// Pull png and insert text
	$camper_pdf = PDF_new();
	pdf_open_file($camper_pdf);
	
	
	$camper_orig = pdf_open_image_file($camper_pdf, "tiff", "camper-registration.tiff");
	
	$orig_width = pdf_get_value($camper_pdf, "imagewidth", $camper_orig);
	$orig_height = pdf_get_value($camper_pdf, "imageheight", $camper_orig);
	
	
	
	pdf_begin_page($camper_pdf, $orig_width, $orig_height);
	
	pdf_place_image($camper_pdf, $camper_orig, 0, 0, 1);
	pdf_close_image($camper_pdf, $camper_orig);
	
	$font = pdf_findfont($camper_pdf, "Helvetica-Bold",  "winansi",0);
	pdf_setfont($camper_pdf, $font, 12);
	
	//////
	//Insert Camper Info
	// Week 1
	pdf_show_xy($camper_pdf, "x", 102, 723);
	// Week 2
	pdf_show_xy($camper_pdf, "x", 166, 723);
	
	
	//Name
	pdf_show_xy($camper_pdf, $camper['name'], 55, 675);
	// Age
	pdf_show_xy($camper_pdf, $camper['age'], 330, 675);
	// Gender
	pdf_show_xy($camper_pdf, $camper['gender'], 412, 675);
	// Next Grade
	pdf_show_xy($camper_pdf, $camper['grade'], 538, 675);
	
	
	
	
	// end page
	pdf_end_page($camper_pdf); 
	
	// close and save file
	pdf_close($camper_pdf); 
	
	$file = pdf_get_buffer($camper_pdf);
	
	header("Content-type: application/pdf");
	header("Content-Length: ".strlen($file));
	header("Content-Disposition: inline; filename=Camper_Application.pdf");
	
	echo $file;
	
	pdf_delete($camper_pdf);
}

?> 



